package com.tank.jdk8.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/1/29
 * Time: 18:14
 * To change this template use File | Settings | File Templates.
 */
public class StreamTest3 {

    public static void main(String[] args) {


        List<String> list = Arrays.asList("hello","world","nimei");
        List<String> list2 = Arrays.asList("hello_2","world_2","nimei_2");


        //字母转大写
   //    List<String> upperCaseList =  list.stream().collect(ArrayList::new,(theList,item) -> theList.add(item.toUpperCase()),ArrayList::addAll);
  //     List<String> upperCaseList =  list.stream().map((item) -> item.toUpperCase()).collect(Collectors.toList());
    //    upperCaseList.forEach(System.out::println);

        Stream<List<String>> stream = Stream.of(list,list2);
        //flatMap将流中多个集合合并为一个集合
        //第一步:将每一个集合元素打散为流
        //第二步:再将打散的流再次映射
        stream.flatMap((theList) -> theList.stream()).map(String::toUpperCase).forEach(System.out::println);
    }
}

